using ExampleWebApplication.Entities;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;

namespace ExampleWebApplication.Infraestruture.NHibernate.EntityMappings
{
    public class RegionMap : ClassMapping<Region>
    {
        public RegionMap()
        {
            Table("Region");
            Id(x => x.RegionID, map => { map.Generator(Generators.Identity); map.Column("RegionID"); });
            Property(x => x.RegionDescription, map => { map.Column("RegionDescription"); map.NotNullable(true); map.Length(50); });
            Bag(x => x.Territories, map => { map.Inverse(true); map.Key(key => key.Column("RegionID")); }, rel => rel.OneToMany());
        }
    }
}
